//
//  TZMeViewController.m
//  wangYiCaiPiao
//
//  Created by mac on 16/1/4.
//  Copyright © 2016年 tz. All rights reserved.
//

#import "TZMeViewController.h"
//#import "CZSettingController.h"
//#import "CZHelpController.h"
#import "TZLoginViewController.h"
#import "TZSetController.h"

@interface TZMeViewController ()
@property (nonatomic, strong) UIImageView *logoImageView;
@property (nonatomic, strong) UIButton *loginButton;
@property (nonatomic, strong) UILabel *titleLabel;
@end

@implementation TZMeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.navigationItem setTitle:@"我的彩票"];
    [self setupUI];
}

//更新UI
- (void)setupUI {
    [self addSettingInNav];
    [self addLogoInController];
    [self addLoginButtonInController];
    [self addLabelInController];
}

//登陆按钮点击事件
- (void)loginButtonDidClick {
    TZLoginViewController *loginViewController = [[TZLoginViewController alloc] init];
    [self.navigationController pushViewController:loginViewController animated:YES];
}

//设置按钮
- (void)addSettingInNav {
    UIBarButtonItem *bar = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Mylottery_config"] style:UIBarButtonItemStylePlain target:self action:@selector(settingDidClick)];
    self.navigationItem.rightBarButtonItem = bar;
}

//点击事件
- (void)settingDidClick {
    TZSetController *setTabController = [[TZSetController alloc] init];
    [self.navigationController pushViewController:setTabController animated:YES];
}

//Logo
- (void)addLogoInController {
    self.logoImageView = [[UIImageView alloc] init];
    [self.view addSubview:self.logoImageView];
    [self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.view.mas_right).offset(-20);
        make.left.equalTo(self.view.mas_left).offset(20);
        make.height.mas_equalTo(130);
        make.top.equalTo(self.view.mas_top).offset(40);
    }];
    self.logoImageView.image = [UIImage imageNamed:@"LoginScreen"];
}

//描述文字
- (void)addLabelInController {
    self.titleLabel = [[UILabel alloc] init];
    [self.view addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.top.equalTo(self.logoImageView.mas_bottom).offset(20);
    }];
    self.titleLabel.text = @"网易彩票 圆你一个梦想";
    self.titleLabel.numberOfLines = 0;
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.titleLabel.font = [UIFont systemFontOfSize:20.0];
    self.titleLabel.textColor = [UIColor blackColor];
}

//登陆按钮
- (void)addLoginButtonInController {
    self.loginButton = [[UIButton alloc] init];
    [self.view addSubview:self.loginButton];
    [self.loginButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.view.mas_right).offset(-20);
        make.left.equalTo(self.view.mas_left).offset(20);
        make.height.mas_equalTo(44);
        make.top.equalTo(self.logoImageView.mas_bottom).offset(80);
    }];
    [self.loginButton setBackgroundImage:[UIImage imageNamed:@"RedButton"] forState:UIControlStateNormal];
    [self.loginButton setBackgroundImage:[UIImage imageNamed:@"RedButtonPressed"] forState:UIControlStateHighlighted];
    [self.loginButton setTitle:@"登陆" forState:UIControlStateNormal];
    [self.loginButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.loginButton addTarget:self action:@selector(loginButtonDidClick) forControlEvents:UIControlEventTouchUpInside];
}

@end
